package com.softmaker.repository;

import com.softmaker.entity.UserTask;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

public interface UserTaskRepository extends JpaRepository<UserTask,String> {
    List<UserTask> findUserTaskByUserName(String userName);
    UserTask findUserTaskByUserNameAndTaskName(String userName, String TaskName);
    @Modifying
    void deleteByUserNameAndTaskName(String userName, String taskName);
    @Query(value ="update user_task e set e.state_count=?1 where e.user_id=?2 and e.task_id=?3" ,nativeQuery = true)
    UserTask updateStateByUserIdAndTaskId(int stateCount,String userId,String taskId);
}
